package com.shujia.spark

import org.apache.spark.rdd.RDD
import org.apache.spark.{SparkConf, SparkContext}

object Demo4Filter {

  def main(args: Array[String]): Unit = {

    val conf: SparkConf = new SparkConf().setMaster("local[4]").setAppName("map")
    val sc: SparkContext = new SparkContext(conf)


    val rdd1: RDD[Int] = sc.parallelize(List(1, 2, 3, 4, 5, 6, 7, 8, 9))

    /**
      * filter
      *
      * 汉法返回true保留数据
      * 函数返回false过滤数据
      *
      */


    val filterRDD: RDD[Int] = rdd1.filter(i => i % 2 == 1)


    filterRDD.foreach(println)
  }

}
